<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>产品列表 - 广州桦霖气体有限公司</title>
  <link rel="stylesheet" href="assets/css/common.css">
  <link rel="stylesheet" href="assets/css/products.css">
  <script src="assets/js/common.js"></script>
</head>
<body>
  <header id="header"></header>

  <main>
    <section class="hero">
      <div class="container hero-content">
        <h1>产品中心</h1>
        <p>食品级 / 工业级 / 标准级 / 高纯气体</p>
      </div>
    </section>

    <section class="section">
      <div class="container">
        <h2 class="page-title">全部产品</h2>
        
        <div class="filter-bar">
          <div class="filter-group">
            <label for="cateFilter">分类筛选：</label>
            <select id="cateFilter" class="form-input">
              <option value="">全部分类</option>
              <option value="food">食品级气体</option>
              <option value="industrial">工业气体</option>
              <option value="high-purity">高纯气体</option>
              <option value="standard">标准气体</option>
            </select>
          </div>
          <div class="filter-group">
            <label for="keywordFilter">关键词：</label>
            <input type="text" id="keywordFilter" class="form-input" placeholder="输入产品名称">
          </div>
          <div class="filter-group">
            <button class="btn-small" onclick="filterProducts()">搜索</button>
          </div>
        </div>

        <div class="products-grid" id="proList">
          <div class="product-card" v-for="product in products" :key="product.id">
            <img :src="'./assets/images/product/' + product.path" :alt="product.name">
            <h3>{{ product.name }}</h3>
            <p class="product-price">{{ product.price }}</p>
            <ul>
              <li v-for="(feature, index) in product.feat.slice(0, 3)" :key="index">{{ feature }}</li>
            </ul>
            <a :href="'product-detail.html?id=' + product.id" class="btn-small">查看详情</a>
          </div>
        </div>
      </div>
    </section>
  </main>

  <footer id="footer"></footer>

  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  <script src="assets/js/data.js"></script>
  <script>
    const { createApp, ref, onMounted, computed } = Vue;
    
    createApp({
      setup() {
        const allProducts = ref(products);
        const filteredProducts = ref(products);
        const cateFilter = ref('');
        const keywordFilter = ref('');
        
        onMounted(() => {
          // 创建导航
          document.getElementById('header').innerHTML = createNav('products');
          document.getElementById('footer').innerHTML = createFooter();
        });
        
        const filterProducts = () => {
          filteredProducts.value = allProducts.value.filter(product => {
            const matchesCate = !cateFilter.value || product.cate === cateFilter.value;
            const matchesKeyword = !keywordFilter.value || 
              product.name.includes(keywordFilter.value) || 
              product.feat.some(f => f.includes(keywordFilter.value));
            return matchesCate && matchesKeyword;
          });
        };
        
        return {
          products: filteredProducts,
          cateFilter,
          keywordFilter,
          filterProducts
        };
      }
    }).mount('#proList');
  </script>
</body>
</html>